{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "74ef8d9d",
   "metadata": {},
   "outputs": [],
   "source": [
    "#腐蚀\n",
    "import cv2 as cv\n",
    "import numpy as np\n",
    "\n",
    "img = cv.imread('../data/j.png',0)\n",
    "kernel = np.ones((5,5),np.uint8)    #结构元素，ones所有元素置为1\n",
    "#erode遍历所有像素 应用腐蚀条件判断  iteration迭代次数，迭代越多越瘦\n",
    "erosion = cv.erode(img,kernel,iterations = 1)\n",
    "\n",
    "cv.imshow('img',img)\n",
    "cv.imshow('erosion',erosion)\n",
    "\n",
    "cv.waitKey(0)\n",
    "cv.destroyAllWindows()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47af6c68",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
